/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.core.regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author sunil
 */
public class MainRegEx {

    public static void main(String[] args) {
        //greedy();
        //reluctant();
        //possessive();
        test();
    }

    public static void test(){
        String txt = "sks.255@gmail.com";
        Pattern p = Pattern.compile("[\\w|.]+@\\w+\\.[a-z]{2,}");
        Matcher m = p.matcher(txt);
        System.out.println(m.matches());
        //while(m.find()){
            System.out.println("---> " + m.group());
        //}
        
    }
    
    public static void greedy(){
        String str = "raaam";
        Pattern pattern = Pattern.compile("r[a]+");
        Matcher m = pattern.matcher(str);

        if(m.find()){
            System.out.println("------> " + m.group());
        }

    }
    public static void reluctant(){
        String str = "raaam";
        Pattern pattern = Pattern.compile("r[a]+?");
        Matcher m = pattern.matcher(str);

        if(m.find()){
            System.out.println("------> " + m.group());
        }

    }
    public static void possessive(){
        String str = "raaam";
        Pattern pattern = Pattern.compile("r[a]++");
        Matcher m = pattern.matcher(str);

        if(m.find()){
            System.out.println("------> " + m.group());
        }

    }
}


